<?php
namespace Tongcheng\Controller;
use Think\Controller;
class CommonController extends Controller {
    public function _initialize(){
        $url = $_SERVER["REQUEST_URI"];
        session('wid',2);
        if(strpos($url,'Book')>0 || strpos($url,'Notify2')>0){
            return;
        }
       if(!session('?uid')){
    		$this->redirect("Home/Public/login");
    	}
      
        if(!session('?wid')){
            $this->error('请选择要管理的小程序',U('Home/Index/index'));
        }
    }


    protected function ihttp_post($url, $post_data){
    	$ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        $out = curl_exec($ch);
        curl_close($ch);
        return $out;
    }

    protected function ihttp_get($url, $is_https = true){
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        if($is_https){
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        }
        $out = curl_exec($ch);
        curl_close($ch);
        return $out;
    }
}
